//
//  detailViewController.m
//  timemovie
//
//  Created by Yiqiao on 15/7/27.
//  Copyright (c) 2015年 Yiqiao. All rights reserved.
//

#import "detailViewController.h"

@interface detailViewController ()

@end

@implementation detailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    
    UIWebView *webView = [[UIWebView alloc]initWithFrame:self.view.bounds];
    NSString *filePath = [[NSBundle mainBundle ]pathForResource:@"NBA|新浪NBA|新浪竞技风暴_新浪网.html" ofType:nil];
    NSString *htmlString = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil];
    [webView loadHTMLString:htmlString baseURL:nil];
    
    [self.view addSubview:webView];
   
//    
    NSString *homePath = NSHomeDirectory();
    NSString *docPath = [homePath stringByAppendingPathComponent:@"Documents"];
    
    NSString *file1 = [docPath stringByAppendingPathComponent:@"file1.txt"];
    
    
    NSString *file2 = [docPath stringByAppendingPathComponent:@"file2.plist"];
    
    NSFileManager *manager = [NSFileManager defaultManager];
    
    NSString *str1 = @"pangzi cheats money by selling AWP";
    
    NSError *error = [[NSError alloc ]init];
    
    BOOL success = [str1 writeToFile:file1 atomically:YES encoding:NSUTF8StringEncoding error:&error];
    
    if (!success) {
        NSLog(@"%@",error);
    }
    
    
    
    NSString *str2 = [[NSString alloc]initWithContentsOfFile:file1 encoding:NSUTF8StringEncoding error:nil];
    NSLog(@"%@",str2);
    
    NSDictionary *dictionary  = @{@"key1":@"v1",
                                  @"key2":@1,
                                  @"key3":@"v3"
                                  };
   
    [dictionary writeToFile:file2 atomically:YES];
    
    
    
    
    NSDictionary *attr1 = [manager attributesOfItemAtPath:file1 error:nil];
    
    NSLog(@"%@",attr1);
    
    
    NSArray *subPaths = [manager subpathsAtPath:docPath];
    NSLog(@"%@",subPaths);
    
    
    NSNumber *fileSize1 = [attr1 objectForKey:NSFileSize];
    NSLog(@"%@",fileSize1);
    
    
    NSDictionary *attr2 = [manager attributesOfItemAtPath:file2 error:nil];
    
    NSNumber *fileSize2 = [attr2 objectForKey:NSFileSize];
    NSLog(@"%@",fileSize2);
    
    
    
    
//    NSLog(@"%@",docPath);
//    
//    NSFileManager *manager = [NSFileManager defaultManager];
//    NSString *filep = [homePath stringByAppendingPathComponent:@"file.txt"];
//    
//    [manager createFileAtPath:filep contents:nil attributes:nil];
//    
//    NSString *toPath = [homePath stringByAppendingPathComponent:@"file1.txt"];
//    
//    
//    NSError *error = [[NSError alloc]init];
//    
//    BOOL success = [manager removeItemAtPath:toPath  error:&error];
//    
//    
//    if (!success) {
//        NSLog(@"%@",error);
//        
//    }
//    
//    success = [manager fileExistsAtPath:filep];
//    
//    if (success) {
//        NSLog(@"wenjiancunzai");
//    }
    
    
    
    
    
    
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
